<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/form.css"/>
	</head>
	<body>
		<div class="main">
			<h3>用户注册</h3>
			<div class="login-form">
				<p>
					<input placeholder="请输入手机号"  id="phone" class="username input">
				</p>
				<p>
					<input type="password" placeholder="请输入密码" id="password1"  class="password input">
				</p>
				<p>
					<input type="password" placeholder="请确认密码" id="password2" class="password input">
				</p>
				<p>
					<input type='button' id="register" value="点击注册" class="btn">
				</p>
				<p>
					<input type='button' id="login" value="已有账号?点击登录" class="btn">
				</p>
			</div>
		</div>
	</body>

	<script src="qrcode/jquery2.1.4.js"></script>
	<script src="layer/layer.js"></script>
	<script>
		$(function (){
			$("#login").click(function(){
				location.href="login.html";
			})
			$("#register").click(function(){
				let phone = $("#phone").val();
				let password1 = $("#password1").val();
				let password2 = $("#password2").val();
				if (phone.length !== 11){
					layer.tips("请输入正确的手机号码",'#phone', {tips:1});
				} else {
					if (password1 == password2) {
						let load = layer.load();
						// 发送请求
						$.post("/wx/insertUser.do",{phoneNumber:phone,password:password1},function (data){
							layer.close(load);
							if (data.status == 0){
								layer.msg("注册成功！")
							} else {
								layer.msg("手机号已注册!")
							}
						})
					} else {
						layer.msg("密码输入不匹配");
						$("#password2").val("");
						$("#password1").val("");
					}
				}
			})
		})
	</script>

</html>
